<?php
/***************************************************************
*  Copyright notice
*
*  (c) 2010 Grzegorz Bańka <grzegorz.banka@gmail.com>
*  All rights reserved
*
*  This script is part of the TYPO3 project. The TYPO3 project is
*  free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 2 of the License, or
*  (at your option) any later version.
*
*  The GNU General Public License can be found at
*  http://www.gnu.org/copyleft/gpl.html.
*
*  This script is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
 * [CLASS/FUNCTION INDEX of SCRIPT]
 *
 * Hint: use extdeveval to insert/update function index above.
 */

require_once(PATH_tslib.'class.tslib_pibase.php');


/**
 * Plugin 'FE news edytor' for the 'mt_fenews' extension.
 *
 * @author	Grzegorz Bańka <grzegorz.banka@gmail.com>
 * @package	TYPO3
 * @subpackage	tx_mtfenews
 */
class tx_mtfenews_pi2 extends tslib_pibase {
	var $prefixId      = 'tx_mtfenews_pi2';		// Same as class name
	var $scriptRelPath = 'pi2/class.tx_mtfenews_pi2.php';	// Path to this script relative to the extension dir.
	var $extKey        = 'mt_fenews';	// The extension key.
	var $pi_checkCHash = true;
	
	/**
	 * The main method of the PlugIn
	 *
	 * @param	string		$content: The PlugIn content
	 * @param	array		$conf: The PlugIn configuration
	 * @return	The content that is displayed on the website
	 */
	function main($content, $conf) {
		$this->conf = $conf;
		$this->pi_setPiVarDefaults();
		$this->pi_loadLL();
		

	}
	function show_user($content, $conf)
	{
		$where = 'disable=0 AND uid='.intval($conf['user']);
		$res =  $GLOBALS['TYPO3_DB']->exec_SELECTquery('username','fe_users',$where,'','',1);

		while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))
		{
			$return = $row['username'];
		}
		return $return;
	}
	function show_user_link($content, $conf)
	{
		if($conf['user_url']!='') $user_url=$conf['user_url'];
		else $user_url='&tx_mmforum_pi1[action]=forum_view_profil&tx_mmforum_pi1[user_id]='.$conf['user'];

		$array_param = array(
		'useCacheHash' =>1,
		'parameter' => $conf['pid'].' _self',
		'additionalParams' => $user_url,
		'returnLast'	=>	'url',
		);
		
		return $this->cObj->typolink('',$array_param);	
	}
	function show_tag($content, $conf)
	{	
		$pid=$conf['tag_pid'];
		$tag=$conf['tag'];
		$link=array();
		if(strlen($tag)>3)
		{
			$tag=stristr($tag,',')?explode(',',$tag):array($tag);
			for($i=0; $i<count($tag); $i++)
			{
				$array_param = array(
				'parameter' => $pid.' _self',
				'additionalParams' => '&tx_ttnews[swords]='.$tag[$i]
				);
			
				$link[]=$this->cObj->typolink($tag[$i],$array_param);
			}
		}
		return implode($conf['tag_separation'],$link);
	}
}



if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/mt_fenews/pi2/class.tx_mtfenews_pi2.php'])	{
	include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/mt_fenews/pi2/class.tx_mtfenews_pi2.php']);
}

?>